const mongoose = require("./index");

const roleSchema = new mongoose.Schema(
	{
		// 角色标识
		key: {
			type: String,
			required: [true, "角色标识不能为空"],
			unique: [true, "角色标识不能重复"],
		},
		// 角色名称
		name: {
			type: String,
			required: [true, "角色名称不能为空"],
			unique: [true, "角色名称不能重复"],
		},
		// 角色权限
		permissions: {
			type: [mongoose.Schema.Types.ObjectId],
			required: [true, "角色权限不能为空"],
		},
		// 角色状态
		status: {
			type: String,
			enum: ["disable", "enable"],
			default: "enable",
		},
	},
	{ timeseries: true }
);

module.exports = mongoose.model("Role", roleSchema);
